package com.ruoyi.park.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.park.domain.CompanySignContract;
import com.ruoyi.park.mapper.CompanySignContractMapper;
import com.ruoyi.park.service.ICompanySignContractService;
import org.springframework.stereotype.Service;

@Service
public class CompanySignContractServiceImpl extends ServiceImpl<CompanySignContractMapper, CompanySignContract> implements ICompanySignContractService {

    @Override
    public void rescind(Long id) {
        CompanySignContract companySignContract = this.baseMapper.selectById(id);
        companySignContract.setSignStatus("0");
        this.baseMapper.updateById(companySignContract);
    }

    @Override
    public void rescind(Long parkId, Long companyId) {
        CompanySignContract companySignContract = this.baseMapper.selectOne(new LambdaQueryWrapper<CompanySignContract>().eq(CompanySignContract::getParkId,parkId).eq(CompanySignContract::getCompanyId,companyId).orderByDesc(CompanySignContract::getStartTime).last("limit 1"));
        companySignContract.setSignStatus("0");
        this.baseMapper.updateById(companySignContract);
    }

}
